home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 34 / Amiga Format CD34 (1998-11-20)(Future Publishing)(GB)[!][Christmas issue].iso / -seriously_amiga- / programming / basic / blitzc2p / c2p / c2pgeneric.ascii < prev    next >
Text File  |  1998-10-01  |  8KB  |  486 lines

  1. WBStartup
  2. NoCli
  3.  
  4. ; 030/50 results:
  5.  
  6. ; 320x200 @40.1fps
  7. ; 320x256 @30.7fps
  8.  
  9. ; 040/25 results:
  10.  
  11. ; 320x200 @42fps DoublePAL or 44fps PAL
  12. ; 320x256 @31fps DoublePAL or 34fps PAL
  13. ; 320x240 @33.7fps DoublePAL or 36.5fps PAL
  14.  
  15. #c2pBPLX=320
  16. #c2pBPLY=256
  17. #c2pBPLSIZE=(#c2pBPLX*#c2pBPLY)/8
  18.  
  19. #scrwidth=#c2pBPLX
  20. #scrheight=#c2pBPLY
  21. #screensize=#scrwidth*#scrheight
  22.  
  23. ; 060 friendly version
  24. ;       modulo  max res fscreen compu
  25. ; c2p1x1_8_c5     no  320x256?  no  030
  26.  
  27. Statement c2pGenericInit{A.l,B.l}
  28.  
  29.   ;A.l=d0=Width.w
  30.   ;B.l=d1=Height.w
  31.  
  32. ; d0.w  chunkyx [chunky-pixels]
  33. ; d1.w  chunkyy [chunky-pixels]
  34. ; d3.w  scroffsy [screen-pixels]
  35.  
  36.   MOVEQ.l #0,d3 ; Y offset
  37.  
  38. c2p1x1_8_c5_init
  39.   LEA c2p_data(pc),a0
  40.   ANDI.l  #$ffff,d0
  41.   MULU.w  d0,d3
  42.   LSR.l #3,d3
  43.   MOVE.l  d3,c2p_scroffs-c2p_data(a0)
  44.   MULU.w  d0,d1
  45.   MOVE.l  d1,c2p_pixels-c2p_data(a0)
  46. AsmExit
  47. End Statement
  48.  
  49. Statement c2pGeneric{A.l,B.l}
  50.  
  51.   MOVE.l  d0,a0 ; Chunky
  52.   MOVE.l  d1,a1 ; Planar
  53.  
  54. ; a0  c2pscreen
  55. ; a1  bitplanes
  56.  
  57. c2p1x1_8_c5
  58.   MOVEM.l a3-a6,-(a7)
  59.  
  60.   LEA c2p_data(pc),a2
  61.  
  62.   MOVE.l  #$33333333,d5
  63.   MOVE.l  #$55555555,a6
  64.  
  65.   ADD.w #c2pBPLSIZE,a1
  66.   ADD.l c2p_scroffs-c2p_data(a2),a1
  67.  
  68.   MOVE.l  c2p_pixels-c2p_data(a2),a2
  69.   ADD.l a0,a2
  70.   CMP.l a0,a2
  71.   BEQ _none
  72.  
  73.   MOVEM.l a0-a1,-(a7)
  74.  
  75.   MOVE.l  (a0)+,d0
  76.   MOVE.l  (a0)+,d2
  77.   MOVE.l  (a0)+,d1
  78.   MOVE.l  (a0)+,d3
  79.  
  80.   MOVE.l  #$0f0f0f0f,d4   ; Merge 4x1, part 1
  81.   AND.l d4,d0
  82.   AND.l d4,d1
  83.   AND.l d4,d2
  84.   AND.l d4,d3
  85.   LSL.l #4,d0
  86.   LSL.l #4,d1
  87.   OR.l  d2,d0
  88.   OR.l  d3,d1
  89.  
  90.   MOVE.l  (a0)+,d2
  91.   MOVE.l  (a0)+,d6
  92.   MOVE.l  (a0)+,d3
  93.   MOVE.l  (a0)+,d7
  94.  
  95.   AND.l d4,d2     ; Merge 4x1, part 2
  96.   AND.l d4,d6
  97.   AND.l d4,d3
  98.   AND.l d4,d7
  99.   LSL.l #4,d2
  100.   LSL.l #4,d3
  101.   OR.l  d6,d2
  102.   OR.l  d7,d3
  103.  
  104.   MOVE.w  d2,d6     ; Swap 16x2
  105.   MOVE.w  d3,d7
  106.   MOVE.w  d0,d2
  107.   MOVE.w  d1,d3
  108.   SWAP  d2
  109.   SWAP  d3
  110.   MOVE.w  d2,d0
  111.   MOVE.w  d3,d1
  112.   MOVE.w  d6,d2
  113.   MOVE.w  d7,d3
  114.  
  115.   MOVE.l  d2,d6     ; Swap 2x2
  116.   MOVE.l  d3,d7
  117.   LSR.l #2,d6
  118.   LSR.l #2,d7
  119.   EOR.l d0,d6
  120.   EOR.l d1,d7
  121.   AND.l d5,d6
  122.   AND.l d5,d7
  123.   EOR.l d6,d0
  124.   EOR.l d7,d1
  125.   LSL.l #2,d6
  126.   LSL.l #2,d7
  127.   EOR.l d6,d2
  128.   EOR.l d7,d3
  129.  
  130.   MOVE.l  #$00ff00ff,d4
  131.   MOVE.l  d1,d6     ; Swap 8x1
  132.   MOVE.l  d3,d7
  133.   LSR.l #8,d6
  134.   LSR.l #8,d7
  135.   EOR.l d0,d6
  136.   EOR.l d2,d7
  137.   BRA _start1
  138. _x1
  139.   MOVE.l  (a0)+,d0
  140.   MOVE.l  (a0)+,d2
  141.   MOVE.l  (a0)+,d1
  142.   MOVE.l  (a0)+,d3
  143.   MOVE.l  d7,-c2pBPLSIZE(a1)
  144.  
  145.   MOVE.l  #$0f0f0f0f,d4   ; Merge 4x1, part 1
  146.   AND.l d4,d0
  147.   AND.l d4,d1
  148.   AND.l d4,d2
  149.   AND.l d4,d3
  150.   LSL.l #4,d0
  151.   LSL.l #4,d1
  152.   OR.l  d2,d0
  153.   OR.l  d3,d1
  154.  
  155.   MOVE.l  (a0)+,d2
  156.   MOVE.l  (a0)+,d6
  157.   MOVE.l  (a0)+,d3
  158.   MOVE.l  (a0)+,d7
  159.   MOVE.l  a3,c2pBPLSIZE(a1)
  160.  
  161.   AND.l d4,d2     ; Merge 4x1, part 2
  162.   AND.l d4,d6
  163.   AND.l d4,d3
  164.   AND.l d4,d7
  165.   LSL.l #4,d2
  166.   LSL.l #4,d3
  167.   OR.l  d6,d2
  168.   OR.l  d7,d3
  169.  
  170.   MOVE.w  d2,d6     ; Swap 16x2
  171.   MOVE.w  d3,d7
  172.   MOVE.w  d0,d2
  173.   MOVE.w  d1,d3
  174.   SWAP  d2
  175.   SWAP  d3
  176.   MOVE.w  d2,d0
  177.   MOVE.w  d3,d1
  178.   MOVE.w  d6,d2
  179.   MOVE.w  d7,d3
  180.   MOVE.l  a4,c2pBPLSIZE*2(a1)
  181.  
  182.   MOVE.l  d2,d6     ; Swap 2x2
  183.   MOVE.l  d3,d7
  184.   LSR.l #2,d6
  185.   LSR.l #2,d7
  186.   EOR.l d0,d6
  187.   EOR.l d1,d7
  188.   AND.l d5,d6
  189.   AND.l d5,d7
  190.   EOR.l d6,d0
  191.   EOR.l d7,d1
  192.   LSL.l #2,d6
  193.   LSL.l #2,d7
  194.   EOR.l d6,d2
  195.   EOR.l d7,d3
  196.  
  197.   MOVE.l  #$00ff00ff,d4
  198.   MOVE.l  d1,d6     ; Swap 8x1
  199.   MOVE.l  d3,d7
  200.   LSR.l #8,d6
  201.   LSR.l #8,d7
  202.   EOR.l d0,d6
  203.   EOR.l d2,d7
  204.   MOVE.l  a5,(a1)+
  205. _start1
  206.   AND.l d4,d6
  207.   AND.l d4,d7
  208.   EOR.l d6,d0
  209.   EOR.l d7,d2
  210.   LSL.l #8,d6
  211.   LSL.l #8,d7
  212.   EOR.l d6,d1
  213.   EOR.l d7,d3
  214.  
  215.   MOVE.l  a6,d4
  216.   MOVE.l  d1,d6     ; Swap 1x1
  217.   MOVE.l  d3,d7
  218.   LSR.l #1,d6
  219.   LSR.l #1,d7
  220.   EOR.l d0,d6
  221.   EOR.l d2,d7
  222.   AND.l d4,d6
  223.   AND.l d4,d7
  224.   EOR.l d6,d0
  225.   EOR.l d7,d2
  226.   ADD.l d6,d6
  227.   ADD.l d7,d7
  228.   EOR.l d1,d6
  229.   EOR.l d3,d7
  230.  
  231.   MOVE.l  d0,a4
  232.   MOVE.l  d2,a5
  233.   MOVE.l  d6,a3
  234.  
  235.   CMPA.l  a0,a2
  236.   BNE _x1
  237.   MOVE.l  d7,-c2pBPLSIZE(a1)
  238.   MOVE.l  a3,c2pBPLSIZE(a1)
  239.   MOVE.l  a4,c2pBPLSIZE*2(a1)
  240.   MOVE.l  a5,(a1)+
  241.  
  242.   MOVEM.l (a7)+,a0-a1
  243.   ADD.l #c2pBPLSIZE*4,a1
  244.  
  245.   MOVE.l  (a0)+,d0
  246.   MOVE.l  (a0)+,d2
  247.   MOVE.l  (a0)+,d1
  248.   MOVE.l  (a0)+,d3
  249.  
  250.   MOVE.l  #$f0f0f0f0,d4   ; Merge 4x1, part 1
  251.   AND.l d4,d0
  252.   AND.l d4,d1
  253.   AND.l d4,d2
  254.   AND.l d4,d3
  255.   LSR.l #4,d2
  256.   LSR.l #4,d3
  257.   OR.l  d2,d0
  258.   OR.l  d3,d1
  259.  
  260.   MOVE.l  (a0)+,d2
  261.   MOVE.l  (a0)+,d6
  262.   MOVE.l  (a0)+,d3
  263.   MOVE.l  (a0)+,d7
  264.  
  265.   AND.l d4,d2     ; Merge 4x1, part 2
  266.   AND.l d4,d6
  267.   AND.l d4,d3
  268.   AND.l d4,d7
  269.   LSR.l #4,d6
  270.   LSR.l #4,d7
  271.   OR.l  d6,d2
  272.   OR.l  d7,d3
  273.  
  274.   MOVE.w  d2,d6     ; Swap 16x2
  275.   MOVE.w  d3,d7
  276.   MOVE.w  d0,d2
  277.   MOVE.w  d1,d3
  278.   SWAP  d2
  279.   SWAP  d3
  280.   MOVE.w  d2,d0
  281.   MOVE.w  d3,d1
  282.   MOVE.w  d6,d2
  283.   MOVE.w  d7,d3
  284.  
  285.   MOVE.l  d2,d6     ; Swap 2x2
  286.   MOVE.l  d3,d7
  287.   LSR.l #2,d6
  288.   LSR.l #2,d7
  289.   EOR.l d0,d6
  290.   EOR.l d1,d7
  291.   AND.l d5,d6
  292.   AND.l d5,d7
  293.   EOR.l d6,d0
  294.   EOR.l d7,d1
  295.   LSL.l #2,d6
  296.   LSL.l #2,d7
  297.   EOR.l d6,d2
  298.   EOR.l d7,d3
  299.  
  300.   MOVE.l  #$00ff00ff,d4
  301.   MOVE.l  d1,d6     ; Swap 8x1
  302.   MOVE.l  d3,d7
  303.   LSR.l #8,d6
  304.   LSR.l #8,d7
  305.   EOR.l d0,d6
  306.   EOR.l d2,d7
  307.   BRA _start2
  308. _x2
  309.   MOVE.l  (a0)+,d0
  310.   MOVE.l  (a0)+,d2
  311.   MOVE.l  (a0)+,d1
  312.   MOVE.l  (a0)+,d3
  313.   MOVE.l  d7,-c2pBPLSIZE(a1)
  314.  
  315.   MOVE.l  #$f0f0f0f0,d4   ; Merge 4x1, part 1
  316.   AND.l d4,d0
  317.   AND.l d4,d1
  318.   AND.l d4,d2
  319.   AND.l d4,d3
  320.   LSR.l #4,d2
  321.   LSR.l #4,d3
  322.   OR.l  d2,d0
  323.   OR.l  d3,d1
  324.  
  325.   MOVE.l  (a0)+,d2
  326.   MOVE.l  (a0)+,d6
  327.   MOVE.l  (a0)+,d3
  328.   MOVE.l  (a0)+,d7
  329.   MOVE.l  a3,c2pBPLSIZE(a1)
  330.  
  331.   AND.l d4,d2     ; Merge 4x1, part 2
  332.   AND.l d4,d6
  333.   AND.l d4,d3
  334.   AND.l d4,d7
  335.   LSR.l #4,d6
  336.   LSR.l #4,d7
  337.   OR.l  d6,d2
  338.   OR.l  d7,d3
  339.  
  340.   MOVE.w  d2,d6     ; Swap 16x2
  341.   MOVE.w  d3,d7
  342.   MOVE.w  d0,d2
  343.   MOVE.w  d1,d3
  344.   SWAP  d2
  345.   SWAP  d3
  346.   MOVE.w  d2,d0
  347.   MOVE.w  d3,d1
  348.   MOVE.w  d6,d2
  349.   MOVE.w  d7,d3
  350.   MOVE.l  a4,c2pBPLSIZE*2(a1)
  351.  
  352.   MOVE.l  d2,d6     ; Swap 2x2
  353.   MOVE.l  d3,d7
  354.   LSR.l #2,d6
  355.   LSR.l #2,d7
  356.   EOR.l d0,d6
  357.   EOR.l d1,d7
  358.   AND.l d5,d6
  359.   AND.l d5,d7
  360.   EOR.l d6,d0
  361.   EOR.l d7,d1
  362.   LSL.l #2,d6
  363.   LSL.l #2,d7
  364.   EOR.l d6,d2
  365.   EOR.l d7,d3
  366.  
  367.   MOVE.l  #$00ff00ff,d4
  368.   MOVE.l  d1,d6     ; Swap 8x1
  369.   MOVE.l  d3,d7
  370.   LSR.l #8,d6
  371.   LSR.l #8,d7
  372.   EOR.l d0,d6
  373.   EOR.l d2,d7
  374.   MOVE.l  a5,(a1)+
  375. _start2
  376.   AND.l d4,d6
  377.   AND.l d4,d7
  378.   EOR.l d6,d0
  379.   EOR.l d7,d2
  380.   LSL.l #8,d6
  381.   LSL.l #8,d7
  382.   EOR.l d6,d1
  383.   EOR.l d7,d3
  384.  
  385.   MOVE.l  a6,d4
  386.   MOVE.l  d1,d6     ; Swap 1x1
  387.   MOVE.l  d3,d7
  388.   LSR.l #1,d6
  389.   LSR.l #1,d7
  390.   EOR.l d0,d6
  391.   EOR.l d2,d7
  392.   AND.l d4,d6
  393.   AND.l d4,d7
  394.   EOR.l d6,d0
  395.   EOR.l d7,d2
  396.   ADD.l d6,d6
  397.   ADD.l d7,d7
  398.   EOR.l d1,d6
  399.   EOR.l d3,d7
  400.  
  401.   MOVE.l  d0,a4
  402.   MOVE.l  d2,a5
  403.   MOVE.l  d6,a3
  404.  
  405.   CMPA.l  a0,a2
  406.   BNE _x2
  407.   MOVE.l  d7,-c2pBPLSIZE(a1)
  408.   MOVE.l  a3,c2pBPLSIZE(a1)
  409.   MOVE.l  a4,c2pBPLSIZE*2(a1)
  410.   MOVE.l  a5,(a1)+
  411.  
  412. _none
  413.   MOVEM.l (a7)+,a3-a6
  414.   AsmExit
  415.  
  416.   Even4
  417. c2p_data
  418. c2p_screen: Dc.l 0
  419. c2p_scroffs: Dc.l 0
  420. c2p_scroffs2: Dc.l 0
  421. c2p_c2pBPLSIZE: Dc.l 0
  422. c2p_pixels: Dc.l 0
  423. c2p_pixels2: Dc.l 0
  424. c2p_pixels4: Dc.l 0
  425. c2p_pixels8: Dc.l 0
  426. c2p_pixels16: Dc.l 0
  427. c2p_chunkyx16: Dc.w 0
  428. c2p_chunkyx32: Dc.w 0
  429. c2p_chunkyy: Dc.w 0
  430. c2p_rowmod: Dc.w 0
  431.   Ds.l  16
  432. End Statement
  433.  
  434.  
  435.  
  436. .blitzprogram
  437. ; Setup
  438. InitBank 0,(#scrwidth*#scrheight)+1000,2|65536 ; Chipram planar buffer
  439. CludgeBitMap 0,#scrwidth,#scrheight,8,Bank(0)
  440. InitPalette 0,256
  441. For c=0 To 255
  442.   AGAPalRGB 0,c,Rnd(c),Rnd(c),Rnd(c)
  443. Next c
  444. AGAPalRGB 0,0,0,0,0
  445. Screen 0,0,0,#scrwidth,#scrheight,8,0,"c2p test",0,0,0
  446. Use Palette 0
  447. VWait 50
  448. baseaddress1.l=AllocMem(#scrwidth*#scrheight,$10000) ; Fastram chunky buffer
  449.  
  450. ; Put something into the chunky buffer so we can see it working
  451. GetReg a0,baseaddress1
  452. MOVE.l  #0,d0
  453. MOVE.l  #screensize-1,d1
  454. cloop
  455.   MOVE.b  d0,(a0)+
  456.   ADDQ.l  #1,d0
  457.   SUBQ.l  #1,d1
  458.   TST.l   d1
  459.   BLT     done
  460.   BRA     cloop
  461. done
  462.  
  463. ; Do the c2p test
  464. c2pGenericInit{#scrwidth,#scrheight}
  465. VWait 20
  466. Forbid_
  467. VWait
  468. ResetTimer
  469. For time=1 To 800
  470.   c2pGeneric{baseaddress1,Bank(0)} ; Convert chunky to planar
  471. Next time
  472. t=Ticks
  473. VWait 2 : Permit_
  474. VWait 20
  475. FindScreen 0
  476. Window 0,0,11,640,100,0,"Test results for c2p",0,0
  477. WindowOutput 0
  478. NPrint "Routine performed @ ",50/(t/800),"fps - ",t," ticks"
  479. NPrint " "
  480. NPrint "Press mousebutton..."
  481. Free Screen 0
  482. MouseWait
  483. Free Window 0
  484. End
  485.  
  486.